package com.imooc.pan.converter;


import com.imooc.pan.entity.StorageBusiness;
import com.imooc.pan.entity.StorageOrder;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;

/**
 * 用户模块实体转化工具类
 */
@Mapper(componentModel = "spring")
public interface OrdersConverter {
    
    @Mapping(source = "storageBusiness.id",target = "businessId")
    @Mapping(source = "storageBusiness.projectName",target = "businessName")
    @Mapping(source = "storageBusiness.payPrice",target = "totalPrice")
    @Mapping(source = "storageBusiness.projectName",target = "orderName")
    @Mapping(target = "userId", expression = "java(cn.dev33.satoken.stp.StpUtil.getLoginIdAsLong())")
    @Mapping(target = "createTime", expression = "java(cn.hutool.core.date.DateUtil.date())")
    @Mapping(target = "id", expression = "java(cn.hutool.core.util.IdUtil.getSnowflakeNextId())")
    @Mapping(source = "storageBusiness.storageSize", target = "businessSize")
    @Mapping(source = "storageBusiness.projectDuration", target = "businessDuration")
    StorageOrder assembleStorageOrderInfo(StorageBusiness storageBusiness);
}
